let nums = [0, 3, 7, 2, 5, 8, 4, 6, 0, 1]
var longestConsecutive = function (nums) {
    if (nums.length === 0) {
        return 0
    }
    let k = 0
    const set = new Set(nums)
    for (let num of set) {
        if (!set.has(num - 1)) {
            let ans = 1
            let curnum = num
            while (set.has(curnum + 1)) {
                ans += 1
                curnum += 1
            }
            k = Math.max(k, ans)
        }
    }
    return k
};
console.log(longestConsecutive(nums));
